#include <stdio.h>

void printPyramid(char letter);

int main() {
    char input;
    printf("input a letter:");
    scanf("%c", &input);
    if (!isalpha(input)) {
        printf("Invalid character!\n");
    } else {
        if (islower(input)) {
            input = toupper(input);
        }
        printPyramid(input);
    }
    return 0;
}

void printPyramid(char letter) {
    for (char i = 'A'; i <= letter; i++) {
        for (char j = letter; j > i; j--) {
            printf(" ");
        }
        for (char k = 'A'; k <= i; k++) {
            printf("%c", k);
        }
        for (char l = i - 1; l >= 'A'; l--) {
            printf("%c", l);
        }
        printf("\n");
    }
}


//以下是题目
/*Lab 2-2 (3分)
Receiving a letter input by user. 
If it is an uppercase letters, such as "C", the required output follows the letter of the pyramid, where "_" represents a space:
 __A 
_ABA 
ABCBA 
If it is a lowercase letters, such as "f", first converts it to the uppercase letters "F", then output the uppercase letters pyramid:
 _____A
 ____ABA
 ___ABCBC
 __ABCDCBA
 _ABCDEDCBA
 ABCDEFEDCBA
Specific requirements:
(1) If the input is a non-letters, you should give error message;
(2) The input and output should be consistent with the following I / O samples. "_" is not need to output.
 
Tips:
Try to use the following sentence after every scanf or getc functions when your result is confusing.
fflush(stdin);

Sample1:
c
  A 
 ABA
ABCBA

Sample2:
F
     A
    ABA
   ABCBA
  ABCDCBA
 ABCDEDCBA
ABCDEFEDCBA

Sample3:
-
Invalid character!*/
